home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / OPTIMIZE / COLLECTN.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-16  |  17.7 KB  |  532 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
  3. Begin VB.Form frmCollection 
  4.    Caption         =   "Collections"
  5.    ClientHeight    =   5970
  6.    ClientLeft      =   4320
  7.    ClientTop       =   1755
  8.    ClientWidth     =   5865
  9.    LinkTopic       =   "Form1"
  10.    LockControls    =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   5970
  13.    ScaleWidth      =   5865
  14.    Begin VB.CommandButton cmdType 
  15.       Caption         =   "For Next"
  16.       Height          =   450
  17.       HelpContextID   =   1
  18.       Index           =   6
  19.       Left            =   120
  20.       TabIndex        =   8
  21.       Top             =   4980
  22.       Width           =   2415
  23.    End
  24.    Begin VB.CommandButton cmdType 
  25.       Caption         =   "For Each"
  26.       Height          =   450
  27.       Index           =   5
  28.       Left            =   120
  29.       TabIndex        =   7
  30.       Top             =   4485
  31.       Width           =   2415
  32.    End
  33.    Begin VB.TextBox txtLoopCount 
  34.       Height          =   320
  35.       Index           =   2
  36.       Left            =   4605
  37.       TabIndex        =   9
  38.       Text            =   "2000"
  39.       Top             =   4050
  40.       Width           =   1150
  41.    End
  42.    Begin VB.CommandButton cmdType 
  43.       Caption         =   "Retrieve By Index"
  44.       Height          =   450
  45.       HelpContextID   =   1
  46.       Index           =   4
  47.       Left            =   120
  48.       TabIndex        =   5
  49.       Top             =   3255
  50.       Width           =   2415
  51.    End
  52.    Begin VB.CommandButton cmdType 
  53.       Caption         =   "Retrieve By Key"
  54.       Height          =   450
  55.       Index           =   3
  56.       Left            =   120
  57.       TabIndex        =   4
  58.       Top             =   2760
  59.       Width           =   2415
  60.    End
  61.    Begin VB.TextBox txtLoopCount 
  62.       Height          =   320
  63.       Index           =   1
  64.       Left            =   4600
  65.       TabIndex        =   6
  66.       Text            =   "2000"
  67.       Top             =   2325
  68.       Width           =   1150
  69.    End
  70.    Begin VB.CommandButton cmdType 
  71.       Caption         =   "Add After"
  72.       Height          =   450
  73.       HelpContextID   =   1
  74.       Index           =   2
  75.       Left            =   120
  76.       TabIndex        =   2
  77.       Top             =   1500
  78.       Width           =   2415
  79.    End
  80.    Begin VB.TextBox txtLoopCount 
  81.       Height          =   320
  82.       Index           =   0
  83.       Left            =   4600
  84.       TabIndex        =   3
  85.       Text            =   "1000"
  86.       Top             =   75
  87.       Width           =   1150
  88.    End
  89.    Begin VB.CommandButton cmdType 
  90.       Caption         =   "Add Item"
  91.       Height          =   450
  92.       Index           =   0
  93.       Left            =   120
  94.       TabIndex        =   0
  95.       Top             =   510
  96.       Width           =   2415
  97.    End
  98.    Begin VB.CommandButton cmdType 
  99.       Caption         =   "Add Before"
  100.       Height          =   450
  101.       HelpContextID   =   1
  102.       Index           =   1
  103.       Left            =   120
  104.       TabIndex        =   1
  105.       Top             =   1005
  106.       Width           =   2415
  107.    End
  108.    Begin ComctlLib.ProgressBar ProgBar 
  109.       Height          =   195
  110.       Left            =   2880
  111.       TabIndex        =   21
  112.       Top             =   5745
  113.       Width           =   2700
  114.       _ExtentX        =   4763
  115.       _ExtentY        =   344
  116.       MouseIcon       =   "Collectn.frx":0000
  117.    End
  118.    Begin ComctlLib.StatusBar StatusBar 
  119.       Align           =   2  'Align Bottom
  120.       Height          =   270
  121.       Left            =   0
  122.       TabIndex        =   20
  123.       Top             =   5700
  124.       Width           =   5865
  125.       _ExtentX        =   10345
  126.       _ExtentY        =   476
  127.       SimpleText      =   ""
  128.       BeginProperty Panels {2C787A51-E01C-11CF-8E74-00A0C90F26F8} 
  129.          NumPanels       =   2
  130.          BeginProperty Panel1 {2C787A53-E01C-11CF-8E74-00A0C90F26F8} 
  131.             Object.Width           =   4939
  132.             MinWidth        =   4939
  133.             Text            =   ""
  134.             TextSave        =   ""
  135.             Key             =   ""
  136.             Object.Tag             =   ""
  137.          EndProperty
  138.          BeginProperty Panel2 {2C787A53-E01C-11CF-8E74-00A0C90F26F8} 
  139.             Object.Width           =   4904
  140.             MinWidth        =   4904
  141.             Text            =   ""
  142.             TextSave        =   ""
  143.             Key             =   ""
  144.             Object.Tag             =   ""
  145.          EndProperty
  146.       EndProperty
  147.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  148.          Name            =   "MS Sans Serif"
  149.          Size            =   8.25
  150.          Charset         =   0
  151.          Weight          =   400
  152.          Underline       =   0   'False
  153.          Italic          =   0   'False
  154.          Strikethrough   =   0   'False
  155.       EndProperty
  156.       MouseIcon       =   "Collectn.frx":001C
  157.    End
  158.    Begin VB.Label lblResult 
  159.       Appearance      =   0  'Flat
  160.       BackColor       =   &H80000005&
  161.       BackStyle       =   0  'Transparent
  162.       Caption         =   "00.00 secs"
  163.       BeginProperty Font 
  164.          Name            =   "MS Sans Serif"
  165.          Size            =   9.75
  166.          Charset         =   0
  167.          Weight          =   700
  168.          Underline       =   0   'False
  169.          Italic          =   0   'False
  170.          Strikethrough   =   0   'False
  171.       EndProperty
  172.       ForeColor       =   &H80000008&
  173.       Height          =   255
  174.       Index           =   6
  175.       Left            =   4605
  176.       TabIndex        =   19
  177.       Top             =   5085
  178.       Width           =   1155
  179.    End
  180.    Begin VB.Label lblResult 
  181.       Appearance      =   0  'Flat
  182.       BackColor       =   &H80000005&
  183.       BackStyle       =   0  'Transparent
  184.       Caption         =   "00.00 secs"
  185.       BeginProperty Font 
  186.          Name            =   "MS Sans Serif"
  187.          Size            =   9.75
  188.          Charset         =   0
  189.          Weight          =   700
  190.          Underline       =   0   'False
  191.          Italic          =   0   'False
  192.          Strikethrough   =   0   'False
  193.       EndProperty
  194.       ForeColor       =   &H80000008&
  195.       Height          =   255
  196.       Index           =   5
  197.       Left            =   4605
  198.       TabIndex        =   18
  199.       Top             =   4590
  200.       Width           =   1155
  201.    End
  202.    Begin VB.Label lblTitle 
  203.       Appearance      =   0  'Flat
  204.       AutoSize        =   -1  'True
  205.       BackColor       =   &H00FFFFFF&
  206.       BackStyle       =   0  'Transparent
  207.       Caption         =   "For Each vs. For Next"
  208.       BeginProperty Font 
  209.          Name            =   "MS Sans Serif"
  210.          Size            =   12
  211.          Charset         =   0
  212.          Weight          =   700
  213.          Underline       =   0   'False
  214.          Italic          =   0   'False
  215.          Strikethrough   =   0   'False
  216.       EndProperty
  217.       ForeColor       =   &H00800000&
  218.       Height          =   300
  219.       Index           =   2
  220.       Left            =   135
  221.       TabIndex        =   17
  222.       Top             =   4050
  223.       Width           =   2610
  224.    End
  225.    Begin VB.Line Line1 
  226.       BorderColor     =   &H00808080&
  227.       Index           =   0
  228.       X1              =   0
  229.       X2              =   7335
  230.       Y1              =   3900
  231.       Y2              =   3900
  232.    End
  233.    Begin VB.Label lblResult 
  234.       Appearance      =   0  'Flat
  235.       BackColor       =   &H80000005&
  236.       BackStyle       =   0  'Transparent
  237.       Caption         =   "00.00 secs"
  238.       BeginProperty Font 
  239.          Name            =   "MS Sans Serif"
  240.          Size            =   9.75
  241.          Charset         =   0
  242.          Weight          =   700
  243.          Underline       =   0   'False
  244.          Italic          =   0   'False
  245.          Strikethrough   =   0   'False
  246.       EndProperty
  247.       ForeColor       =   &H80000008&
  248.       Height          =   255
  249.       Index           =   4
  250.       Left            =   4600
  251.       TabIndex        =   16
  252.       Top             =   3360
  253.       Width           =   1155
  254.    End
  255.    Begin VB.Label lblResult 
  256.       Appearance      =   0  'Flat
  257.       BackColor       =   &H80000005&
  258.       BackStyle       =   0  'Transparent
  259.       Caption         =   "00.00 secs"
  260.       BeginProperty Font 
  261.          Name            =   "MS Sans Serif"
  262.          Size            =   9.75
  263.          Charset         =   0
  264.          Weight          =   700
  265.          Underline       =   0   'False
  266.          Italic          =   0   'False
  267.          Strikethrough   =   0   'False
  268.       EndProperty
  269.       ForeColor       =   &H80000008&
  270.       Height          =   255
  271.       Index           =   3
  272.       Left            =   4600
  273.       TabIndex        =   15
  274.       Top             =   2865
  275.       Width           =   1155
  276.    End
  277.    Begin VB.Label lblTitle 
  278.       Appearance      =   0  'Flat
  279.       AutoSize        =   -1  'True
  280.       BackColor       =   &H00FFFFFF&
  281.       BackStyle       =   0  'Transparent
  282.       Caption         =   "Retrieving Items From Collections"
  283.       BeginProperty Font 
  284.          Name            =   "MS Sans Serif"
  285.          Size            =   12
  286.          Charset         =   0
  287.          Weight          =   700
  288.          Underline       =   0   'False
  289.          Italic          =   0   'False
  290.          Strikethrough   =   0   'False
  291.       EndProperty
  292.       ForeColor       =   &H00800000&
  293.       Height          =   300
  294.       Index           =   1
  295.       Left            =   135
  296.       TabIndex        =   14
  297.       Top             =   2325
  298.       Width           =   4065
  299.    End
  300.    Begin VB.Line Line1 
  301.       BorderColor     =   &H00808080&
  302.       Index           =   3
  303.       X1              =   0
  304.       X2              =   7335
  305.       Y1              =   2175
  306.       Y2              =   2175
  307.    End
  308.    Begin VB.Label lblResult 
  309.       Appearance      =   0  'Flat
  310.       BackColor       =   &H80000005&
  311.       BackStyle       =   0  'Transparent
  312.       Caption         =   "00.00 secs"
  313.       BeginProperty Font 
  314.          Name            =   "MS Sans Serif"
  315.          Size            =   9.75
  316.          Charset         =   0
  317.          Weight          =   700
  318.          Underline       =   0   'False
  319.          Italic          =   0   'False
  320.          Strikethrough   =   0   'False
  321.       EndProperty
  322.       ForeColor       =   &H80000008&
  323.       Height          =   255
  324.       Index           =   2
  325.       Left            =   4600
  326.       TabIndex        =   13
  327.       Top             =   1600
  328.       Width           =   1150
  329.    End
  330.    Begin VB.Label lblTitle 
  331.       Appearance      =   0  'Flat
  332.       AutoSize        =   -1  'True
  333.       BackColor       =   &H00FFFFFF&
  334.       BackStyle       =   0  'Transparent
  335.       Caption         =   "Adding Items to Collections"
  336.       BeginProperty Font 
  337.          Name            =   "MS Sans Serif"
  338.          Size            =   12
  339.          Charset         =   0
  340.          Weight          =   700
  341.          Underline       =   0   'False
  342.          Italic          =   0   'False
  343.          Strikethrough   =   0   'False
  344.       EndProperty
  345.       ForeColor       =   &H00800000&
  346.       Height          =   300
  347.       Index           =   0
  348.       Left            =   135
  349.       TabIndex        =   12
  350.       Top             =   75
  351.       Width           =   3315
  352.    End
  353.    Begin VB.Label lblResult 
  354.       Appearance      =   0  'Flat
  355.       BackColor       =   &H80000005&
  356.       BackStyle       =   0  'Transparent
  357.       Caption         =   "00.00 secs"
  358.       BeginProperty Font 
  359.          Name            =   "MS Sans Serif"
  360.          Size            =   9.75
  361.          Charset         =   0
  362.          Weight          =   700
  363.          Underline       =   0   'False
  364.          Italic          =   0   'False
  365.          Strikethrough   =   0   'False
  366.       EndProperty
  367.       ForeColor       =   &H80000008&
  368.       Height          =   255
  369.       Index           =   0
  370.       Left            =   4600
  371.       TabIndex        =   11
  372.       Top             =   615
  373.       Width           =   1150
  374.    End
  375.    Begin VB.Label lblResult 
  376.       Appearance      =   0  'Flat
  377.       BackColor       =   &H80000005&
  378.       BackStyle       =   0  'Transparent
  379.       Caption         =   "00.00 secs"
  380.       BeginProperty Font 
  381.          Name            =   "MS Sans Serif"
  382.          Size            =   9.75
  383.          Charset         =   0
  384.          Weight          =   700
  385.          Underline       =   0   'False
  386.          Italic          =   0   'False
  387.          Strikethrough   =   0   'False
  388.       EndProperty
  389.       ForeColor       =   &H80000008&
  390.       Height          =   255
  391.       Index           =   1
  392.       Left            =   4600
  393.       TabIndex        =   10
  394.       Top             =   1110
  395.       Width           =   1150
  396.    End
  397.    Begin VB.Line Line1 
  398.       BorderColor     =   &H00FFFFFF&
  399.       BorderWidth     =   2
  400.       Index           =   2
  401.       X1              =   15
  402.       X2              =   7350
  403.       Y1              =   2190
  404.       Y2              =   2175
  405.    End
  406.    Begin VB.Line Line1 
  407.       BorderColor     =   &H00FFFFFF&
  408.       BorderWidth     =   2
  409.       Index           =   1
  410.       X1              =   15
  411.       X2              =   7350
  412.       Y1              =   3915
  413.       Y2              =   3900
  414.    End
  415. Attribute VB_Name = "frmCollection"
  416. Attribute VB_GlobalNameSpace = False
  417. Attribute VB_Creatable = False
  418. Attribute VB_TemplateDerived = False
  419. Attribute VB_PredeclaredId = True
  420. Attribute VB_Exposed = False
  421. Option Explicit
  422. Private Sub cmdType_Click(Index As Integer)
  423.   Dim MyCollection As New Collection
  424.   Dim iCounter As Integer
  425.   Dim dStart As Double, dFinish As Double
  426.   Dim sAnswer As String
  427.   Dim pnlStatus As Panel
  428.   Dim vItem As Variant
  429.   Set pnlStatus = frmCollection.StatusBar.Panels(1)
  430.   Screen.MousePointer = vbHourglass
  431.   dStart = Timer
  432.   Select Case Index
  433.     Case 0  'Add
  434.       For iCounter = 0 To Val(txtLoopCount(0).Text) Step 3
  435.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  436.         MyCollection.Add Item:=CStr(iCounter + 400), Key:=CStr(iCounter + 1)
  437.         MyCollection.Add Item:=CStr(iCounter + 800), Key:=CStr(iCounter + 2)
  438.       Next iCounter
  439.     Case 1 'Add Before
  440.       MyCollection.Add Item:=CStr(1), Key:=CStr(1)
  441.       For iCounter = 2 To Val(txtLoopCount(0).Text) Step 3
  442.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter), Before:=CStr(iCounter - 1)
  443.         MyCollection.Add Item:=CStr(iCounter + 400), Key:=CStr(iCounter + 1), Before:=CStr(iCounter)
  444.         MyCollection.Add Item:=CStr(iCounter + 800), Key:=CStr(iCounter + 2), Before:=CStr(iCounter)
  445.       Next iCounter
  446.     Case 2 'Add After
  447.       MyCollection.Add Item:=CStr(1), Key:=CStr(1)
  448.       For iCounter = 2 To Val(txtLoopCount(0).Text) Step 3
  449.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter), After:=CStr(iCounter - 1)
  450.         MyCollection.Add Item:=CStr(iCounter + 400), Key:=CStr(iCounter + 1), After:=CStr(iCounter)
  451.         MyCollection.Add Item:=CStr(iCounter + 800), Key:=CStr(iCounter + 2), After:=CStr(iCounter)
  452.       Next iCounter
  453.     Case 3  ' Retrieve By Key
  454.       pnlStatus.Text = "Building Collection..."
  455.       StatusBar.Refresh
  456.       ProgBar.Max = Val(txtLoopCount(1).Text)
  457.       ' First add items to the collection
  458.       For iCounter = 1 To Val(txtLoopCount(1).Text)
  459.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  460.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  461.       Next iCounter
  462.       
  463.       pnlStatus.Text = "Retrieving Items..."
  464.       StatusBar.Refresh
  465.       dStart = Timer
  466.       For iCounter = MyCollection.Count To 1 Step -1
  467.         sAnswer = MyCollection(CStr(iCounter))
  468.       Next iCounter
  469.       
  470.     Case 4  ' Retrieve By Index
  471.       pnlStatus.Text = "Building Collection..."
  472.       StatusBar.Refresh
  473.       ProgBar.Max = Val(txtLoopCount(1).Text)
  474.       ' First add items to the collection
  475.       For iCounter = 1 To Val(txtLoopCount(1).Text)
  476.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  477.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  478.       Next iCounter
  479.       
  480.       pnlStatus.Text = "Retrieving Items..."
  481.       StatusBar.Refresh
  482.       dStart = Timer
  483.       For iCounter = MyCollection.Count To 1 Step -1
  484.         sAnswer = MyCollection(iCounter)
  485.       Next iCounter
  486.     Case 5  ' For Each
  487.       pnlStatus.Text = "Building Collection..."
  488.       StatusBar.Refresh
  489.       ProgBar.Max = Val(txtLoopCount(2).Text)
  490.       
  491.       For iCounter = 1 To Val(txtLoopCount(2).Text)
  492.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  493.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  494.       Next iCounter
  495.       
  496.       pnlStatus.Text = "Retrieving Items..."
  497.       StatusBar.Refresh
  498.       
  499.       dStart = Timer
  500.       For Each vItem In MyCollection
  501.         sAnswer = MyCollection(vItem)
  502.       Next vItem
  503.     Case 6  ' For Next
  504.       pnlStatus.Text = "Building Collection..."
  505.       StatusBar.Refresh
  506.       ProgBar.Max = Val(txtLoopCount(2).Text)
  507.       
  508.       For iCounter = 1 To Val(txtLoopCount(2).Text)
  509.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  510.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  511.       Next iCounter
  512.       
  513.       pnlStatus.Text = "Iterating the Collection..."
  514.       StatusBar.Refresh
  515.       
  516.       dStart = Timer
  517.       For iCounter = 1 To MyCollection.Count
  518.         sAnswer = MyCollection(iCounter)
  519.       Next iCounter
  520.       
  521.   End Select
  522.   dFinish = Timer
  523.   Set MyCollection = Nothing
  524.   lblResult(Index).Caption = Format$(dFinish - dStart, "00.00") & " secs."
  525.   pnlStatus.Text = ""
  526.   ProgBar.Value = 0
  527.   Screen.MousePointer = vbDefault
  528. End Sub
  529. Private Sub Form_Load()
  530.   PosForm Me
  531. End Sub
  532.